package com.douqu.game.main.server.entity;


import com.bean.core.util.Utils;
import com.douqu.game.core.e.E_NoticeType;
import com.douqu.game.core.factory.DataFactory;

/**
 * @author wangzhenfei
 *         2018-01-11 18:02
 */
public class NoticeInfo {

    private String id;
    /**
     * 发送内容
     */
    private String content;
    /**
     * 轮询次数
     */
    private int lopperTimes;
    /**
     * 轮询间隔
     */
    private int interval;


    /**
     * 发送公告的gm人员名称
     */
    private String gmName;

    /**
     * 开始时间
     */
    private long startTime;


    /**
     * 当前次数
     */
    private int currentTimes;
    /**
     * 当前秒数
     */
    private int currentSeconds;

    /**
     * 通知的类型
     */
    private E_NoticeType noticeType;

    public NoticeInfo()
    {
        this.id = Utils.getBatchNo();
    }

    public NoticeInfo(String content) {
        this();

        this.startTime = DataFactory.currentTime;
        this.content = content;
        this.noticeType = E_NoticeType.NOTICE_TYPE_OTHER;
    }

    public NoticeInfo(String content, int lopperTimes, int interval, String gmName, long startTime, E_NoticeType noticeType) {
        this();

        this.content = content;
        this.lopperTimes = lopperTimes;
        this.interval = interval;
        this.gmName = gmName;
        this.startTime = startTime;
        this.currentSeconds = interval;//为了进来就执行一次
        this.noticeType = noticeType;
    }




    public String getContent() {
        return content;
    }

    public int getCurrentTimes() {
        return currentTimes;
    }

    public boolean checkParam(){
        return lopperTimes > 0 && interval > 0;
    }


    /**
     * 是否可以发送消息
     * @return
     */
    public boolean canSendMsg(){
        if(canDelete()){
            return false;
        }

        if(currentSeconds == interval){
            currentSeconds = 0;
            currentTimes++;
            return true;
        }else {
            currentSeconds ++;
            return false;
        }
    }

    public boolean canDelete(){
        if(currentTimes == lopperTimes){
            return true;
        }

        return false;
    }


    public void setContent(String content) {
        this.content = content;
    }

    public int getLopperTimes() {
        return lopperTimes;
    }

    public void setLopperTimes(int lopperTimes) {
        this.lopperTimes = lopperTimes;
    }

    public int getInterval() {
        return interval;
    }

    public void setInterval(int interval) {
        this.interval = interval;
    }

    public String getGmName() {
        return gmName;
    }

    public void setGmName(String gmName) {
        this.gmName = gmName;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public void setCurrentTimes(int currentTimes) {
        this.currentTimes = currentTimes;
    }

    public int getCurrentSeconds() {
        return currentSeconds;
    }

    public void setCurrentSeconds(int currentSeconds) {
        this.currentSeconds = currentSeconds;
    }

    public E_NoticeType getNoticeType() {
        return noticeType;
    }

    public void setNoticeType(E_NoticeType noticeType) {
        this.noticeType = noticeType;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
